<%
  if local_assigns.key?(:record_and_post_content)
    record, post_content = record_and_post_content
  else
    record = post_moderation_record
  end
  post = record.post
  if post
    post_view = Thredded::PostView.new(post, policy(post))
  end
  moderation_state_notice_args = {
      moderator: user_link(record.moderator),
      time_ago:  time_ago(record.created_at)
  }
%>
<article id="<%= dom_id(post) %>" class="thredded--post-moderation-record thredded--post-moderation-record-<%= record.moderation_state %>">
  <header class="thredded--post-moderation-record--header">
    <p class="thredded--post-moderation-record--moderation-state-notice">
      <% if record.approved? %>
        <%= t('thredded.moderation.post_approved_html', **moderation_state_notice_args) %>
      <% elsif record.blocked? %>
        <%= t('thredded.moderation.post_blocked_html', **moderation_state_notice_args) %>
      <% end %>
    </p>
    <% if post && post.content != record.post_content %>
      <p class="thredded--post-moderation-record--content-changed-notice">
        <%= t('thredded.moderation.posts_content_changed_since_moderation_html', post_url: post_permalink_path(post)) %>
      </p>
    <% end %>
    <%= content_tag :em, t('thredded.moderation.post_deleted_notice') unless post %>
  </header>
  <article class="thredded--post">
    <% post_user_link = capture do %>
      <% if record.post_user %>
        <%= link_to record.post_user.thredded_display_name, user_moderation_path(record.post_user.id) %>
      <% else %>
        <%= safe_join [record.post_user_name, content_tag(:em, t('thredded.null_user_name'))].compact, ', ' %>
      <% end %>
    <% end %>
    <% if post %>
      <%= render 'thredded/posts_common/header_with_user_and_topic',
                 post: post_view, user: record.post_user, post_user_link: post_user_link %>
    <% else %>
      <header><h2 class="thredded--post--user"><%= post_user_link %></h2></header>
    <% end %>
    <div class="thredded--post--content">
      <%= post_content ||
              render('thredded/moderation/post_moderation_record_content', post_moderation_record: record) %>
    </div>
  </article>
  <%= render 'post_moderation_actions', post: post if post %>
</article>
